package com.cyf.cityguidance;

import com.cyf.cityguidance.network.bean.CarInOutParkingReq;
import com.cyf.cityguidance.network.bean.CarInOutParkingRsp;
import com.cyf.cityguidance.network.bean.UpdateParkingSpaceReq;
import com.cyf.cityguidance.network.bean.UpdateParkingSpaceRsp;
import com.cyf.cityguidance.service.CityguidanceService;
import io.netty.handler.codec.http.HttpUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by cheyifu on 2018/2/6.
 */
@RestController
@RequestMapping(value = "cigyguidance")
@Api(value = "城市向导api")
public class CityguidanceHttpController {

    @Autowired
    CityguidanceService cityguidanceService;

    @ApiOperation(value = "出入场更新剩余停车位")
    @RequestMapping(value = "/carInOutParking", method = RequestMethod.POST)
    CarInOutParkingRsp carInOutParking(@RequestParam String code)
    {
        CarInOutParkingReq req = new CarInOutParkingReq();
        req.setCode(code);

        return cityguidanceService.carInOutParking(req);
    }

    @ApiOperation(value = "更新内存车场剩余停车位")
    @RequestMapping(value = "/updateRemainSpace", method = RequestMethod.POST)
    UpdateParkingSpaceRsp updateParkingSpace(@RequestParam int parkingId,
                                             @RequestParam int remainSpace)
    {
        UpdateParkingSpaceReq req = new UpdateParkingSpaceReq();
        req.setParkingId(parkingId);
        req.setRemainSpace(remainSpace);

        return cityguidanceService.updateRemainParkingSpace(req);
    }



}
